use actix_web::body::BoxBody;
use actix_web::{HttpResponse, ResponseError};
use derive_more::Display;

#[derive(Debug, Display)]
pub enum MyError {
    MsgError(String),
    BadRequest,
    NotFound,
}
impl ResponseError for MyError {
    fn error_response(&self) -> HttpResponse<BoxBody> {
        match self {
            MyError::MsgError(str) => HttpResponse::InternalServerError().body(str.to_string()),
            MyError::NotFound => HttpResponse::InternalServerError().body("Not Found".to_string()),
            MyError::BadRequest => HttpResponse::BadRequest().finish(),
        }
    }
}
